package com.sgcc.operate.service.impl;

import java.util.Date;
import java.util.List;
import java.util.UUID;

import com.sgcc.common.security.service.TokenService;
import com.sgcc.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.sgcc.operate.mapper.OIndiContentMapper;
import com.sgcc.operate.domain.OIndiContent;
import com.sgcc.operate.service.IOIndiContentService;

/**
 * 方案指标内容Service业务层处理
 * 
 * @author sgcc
 * @date 2021-03-24
 */
@Service
public class OIndiContentServiceImpl implements IOIndiContentService 
{
    @Autowired
    private OIndiContentMapper oIndiContentMapper;
    @Autowired
    private TokenService tokenService;
    /**
     * 查询方案指标内容
     * 
     * @param id 方案指标内容ID
     * @return 方案指标内容
     */
    @Override
    public OIndiContent selectOIndiContentById(String id)
    {
        return oIndiContentMapper.selectOIndiContentById(id);
    }

    /**
     * 查询方案指标内容列表
     * 
     * @param oIndiContent 方案指标内容
     * @return 方案指标内容
     */
    @Override
    public List<OIndiContent> selectOIndiContentList(OIndiContent oIndiContent)
    {
        return oIndiContentMapper.selectOIndiContentList(oIndiContent);
    }

    /**
     * 新增方案指标内容
     * 
     * @param oIndiContent 方案指标内容
     * @return 结果
     */
    @Override
    public int insertOIndiContent(OIndiContent oIndiContent)
    {
        LoginUser loginUser = tokenService.getLoginUser();
        oIndiContent.setCreateDate(new Date());
        oIndiContent.setUpdateDate(new Date());
        oIndiContent.setCreateBy(loginUser.getUserid());
        oIndiContent.setUpdateBy(loginUser.getUserid());
        oIndiContent.setDelFlag("0");
        String id = UUID.randomUUID().toString().replaceAll("-", "");
        oIndiContent.setId(id);
        return oIndiContentMapper.insertOIndiContent(oIndiContent);
    }

    /**
     * 修改方案指标内容
     * 
     * @param oIndiContent 方案指标内容
     * @return 结果
     */
    @Override
    public int updateOIndiContent(OIndiContent oIndiContent)
    {
        LoginUser loginUser = tokenService.getLoginUser();
        oIndiContent.setUpdateDate(new Date());
        oIndiContent.setUpdateBy(loginUser.getUserid());
        return oIndiContentMapper.updateOIndiContent(oIndiContent);
    }

    /**
     * 批量删除方案指标内容
     * 
     * @param ids 需要删除的方案指标内容ID
     * @return 结果
     */
    @Override
    public int deleteOIndiContentByIds(String[] ids)
    {
        return oIndiContentMapper.deleteOIndiContentByIds(ids);
    }

    /**
     * 删除方案指标内容信息
     * 
     * @param id 方案指标内容ID
     * @return 结果
     */
    @Override
    public int deleteOIndiContentById(String id)
    {
        return oIndiContentMapper.deleteOIndiContentById(id);
    }
}
